"use client";
import { TaskFields } from "@/queries/fields";
import { gql, useQuery } from "@apollo/client";
import TaskListRender from "./TaskListRender";

const query = gql`
  query GetTasksQuery{
    getSelfTask{
      ${TaskFields}
      _count{
        UserOnTask
      }
    }
    getSelfTeacherCount
  }
`;
const UserPage = () => {
  const { data, error } = useQuery(query);
  return (
    <div>
      <div className="px-4 py-5 sm:px-6">
        <h2 className="text-lg leading-6 font-medium text-gray-900">
          任务列表
        </h2>
      </div>
      <div className="border-t border-gray-200">
        {!error && (
          <TaskListRender
            total={data?.getSelfTeacherCount || 0}
            tasks={data?.getSelfTask || []}
          />
        )}
        {!!error && <div>error</div>}
      </div>
    </div>
  );
};
export default UserPage;
